package com.feisuanyz.rest;

import java.io.Serializable;
import lombok.*;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class RestResult<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private String code;

    private String msg;

    private T data;

    public static <T> RestResult<T> success() {
        return new RestResult<>("000000", "调用成功", null);
    }

    public static <T> RestResult<T> success(T data) {
        return new RestResult<>("000000", "调用成功", data);
    }

    public static <T> RestResult<T> fail(String code, String msg) {
        return new RestResult<>(code, msg, null);
    }

    public static <T> RestResult<T> fail(String code, String msg, T data) {
        return new RestResult<>(code, msg, data);
    }
}